package game.ball;

import com.uqbar.vainilla.DeltaState;

public class Free extends SoccerBallState {
	
	public Free(SoccerBall ball) {
		this.setBall(ball);
	}
	
	public Free(SoccerBall ball,int speed, double i, double j) {
		this.setBall(ball);
		this.setSpeed(speed);
		this.setVersorI(i);
		this.setVersorJ(j);
	}

	@Override
	public void update(DeltaState deltaState) {
		double advanced = this.getSpeed() * deltaState.getDelta();

		this.getBall().moveNormally(this.getVersorI() * advanced, this.getVersorJ() * advanced);
		if(this.getSpeed() > 0)
			this.setSpeed(this.getSpeed() - 0.1); //efecto de disminuir la aceleracion
		else
			this.setSpeed(0);
	}

	// Puede estar sujeto a cambios
	@Override
	protected void moveUpDownWithCentralizedCamera(double x, double y) {
		this.getBall().move(0, y);
		this.getBall().getScene().moveSprites(x, 0);
	}
	
	@Override
	protected void moveRightLeftWithCentralizedCamera(double x, double y) {
		this.getBall().move(x, 0);
		this.getBall().getScene().moveSprites(0, y);
	}

	@Override
	protected void advance(double x, double y) {
		this.getBall().move(x, y);
	}

	@Override
	public boolean isFree() {
		return true;
	}
}
